/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package EstilosWebUI.common;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 *
 * @author QuickDunk
 */
public class AbstractController {

    public static synchronized void info(String msg) {
        FacesMessage facesMsg;
        facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO,msg,msg);
        FacesContext fc = FacesContext.getCurrentInstance();
        fc.addMessage("successInfo", facesMsg);
    }

    public static synchronized void warn(String msg) {
        FacesMessage facesMsg;
        facesMsg = new FacesMessage(FacesMessage.SEVERITY_WARN,msg,msg);
        FacesContext fc = FacesContext.getCurrentInstance();
        fc.addMessage("successInfo", facesMsg);
    }

    public static synchronized void warn(Throwable ex){
        warn(ex.getClass().getSimpleName() + ": "+ex.getMessage());
    }

    public static synchronized void error(String msg) {
        FacesMessage facesMsg;
        facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR,msg,msg);
        FacesContext fc = FacesContext.getCurrentInstance();
        fc.addMessage("successInfo", facesMsg);
    }

    public static synchronized void error(Throwable ex){
        warn(ex.getClass().getSimpleName() + ": "+ex.getMessage());
    }
    
}
